using CollabApp.Application.Services.Auth;
using CollabApp.Application.Services.Users;
using CollabApp.Application.Services.Game;
using CollabApp.Application.Services.Room;
using CollabApp.Domain.Services.Auth;
using CollabApp.Domain.Services.Users;
using CollabApp.Domain.Services.Game;
using CollabApp.Domain.Services.Room;
using CollabApp.Application.Services.Rankings;
using CollabApp.Domain.Services.Rankings;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using CollabApp.Application.Interfaces;

namespace CollabApp.Application;

/// <summary>
/// 扩展方法。应用服务注册。
/// </summary>
public static class ServiceCollectionExtenstion
{
    public static IServiceCollection AddApplication(this IServiceCollection services, IConfiguration configuration)
    {
        // 注册认证服务
        services.AddScoped<IAuthService, AuthService>();

        // 注册用户服务
        services.AddScoped<IUserService, UserService>();
        
        // 注册房间服务
        services.AddScoped<IRoomService, RoomService>();
        
        // 注册游戏核心服务
        services.AddScoped<ICollisionDetectionService, CollisionDetectionService>();
        services.AddScoped<IGameBroadcastService, GameBroadcastService>();
        services.AddScoped<IPowerUpService, PowerUpService>();
        services.AddScoped<IGameResultService, GameResultService>();
        
        // 注册高级游戏机制服务
        services.AddScoped<ISpecialEventService, SpecialEventService>();
        services.AddScoped<IDynamicBalanceService, DynamicBalanceService>();
        services.AddScoped<IMapShrinkingService, MapShrinkingService>();
        
        // 注册其他游戏服务
        services.AddScoped<IGameStateService, GameStateService>();
        services.AddScoped<IPlayerStateService, PlayerStateService>();
        services.AddScoped<IGamePlayService, GamePlayService>();
        services.AddScoped<ITerritoryService, TerritoryService>();
        
        // 注册画线圈地游戏服务
        services.AddScoped<CollabApp.Domain.Services.ILineDrawingGameLogicService, CollabApp.Domain.Services.LineDrawingGameLogicService>();
        services.AddScoped<CollabApp.Application.Interfaces.ILineDrawingGameService, CollabApp.Application.Services.Game.LineDrawingGameService>();
        
        // 注册排行榜服务
        services.AddScoped<IRankingService, RankingService>();

        return services;
    }
}